/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "GameProject.h"

#include "FileSystem.h"
#include "DataSerializer.h"

namespace PQEngine
{
	const std::string GameProject::PERSIS_FILE_NAME="Project.gdt";
	GameProject::GProjectMap GameProject::_map;

	GameProject::GameProject(std::string path)
		: _path(path)
	{
		//create directory contain all project data
		GFileBaseSystem.createDirectory(_path);
		//
		loadAssetsArchive();
		
	}

	void GameProject::loadAssetsArchive()
	{
		GNgGPKArchiveManager.init(_path);
	}

	void GameProject::persist()
	{
		//A project contain the asserts archives,should persist their names.
		
	}

	GameProject* GameProject::get(std::string path)
	{
		GProjectMap::iterator it= _map.find(path);
		if(it!=_map.end()){
			return it->second;
		}

		GameProject* project=new GameProject(path);
		_map.insert(GProjectMap::value_type(path,project));

		return project;
	}

	GPKArchive* GameProject::createAssetArchive(std::string name)
	{
		return GNgGPKArchiveManager.createArchive(name);
	}
}
